@echo off
set LOCAL_MUSIC_PATH=test_music

@rem default play time 30 seconds
set PLAY_TIME=30

cmake -B cmake-build-debug . >> nul
if not %errorlevel%==0 (
   echo Error: cmake configure error.
   exit /b 1
) 
cmake --build cmake-build-debug --target histreamer_player 
if not %errorlevel%==0 (
   echo Error: compile error.
   exit /b 1
)

@rem play local music
for %%i in (%LOCAL_MUSIC_PATH%\*) do ( 
   echo Playing : %%i
   cmake-build-debug\bin\histreamer_player.exe "%%i" %PLAY_TIME% >> play_media.log
   if not %errorlevel%==0 (
	  echo "ERROR: Failed."
   )
)

@rem play http music
echo Playing HTTP : https://img.51miz.com/preview/sound/00/26/73/51miz-S267356-423D33372.mp3
call cmake-build-debug\bin\histreamer_player.exe "https://img.51miz.com/preview/sound/00/26/73/51miz-S267356-423D33372.mp3" 20 >> play_media.log 2>>1
if not %errorlevel%==0 (
   echo "ERROR: Failed."
) 

echo Playing HLS : https://live.ximalaya.com/radio-first-page-app/live/1011/64.m3u8?transcode=aac
call cmake-build-debug\bin\histreamer_player.exe "https://live.ximalaya.com/radio-first-page-app/live/1011/64.m3u8?transcode=aac" 40 >> play_media.log 2>>1
if not %errorlevel%==0 (
   echo "ERROR: Failed."
) 

pause
